<%@page import="com.zpyr.common.StringUtil"%>
<%@page import="com.zpyr.common.CookieManager"%>
<%@page import="com.zpyr.common.SessionManager"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width , user-scalable=no,initial-scale=1.0" />
<%
	boolean isLogin = false;
	SessionManager sess = SessionManager.getInstance(request);
	if(sess.getLoginEmail().equals("")) {
		// 로그인 안된 상태
	}
	else {
		// 로그인 된 상태
		isLogin = true;
	}

%>
<link rel="stylesheet" href="/css/home/layout.css">
<link rel="stylesheet" href="/css/home/common.css">
<link rel="stylesheet" href="/css/home/navigation.css">
<link rel="stylesheet" href="/css/home/memo.css">
<link rel="stylesheet" href="/css/home/table.css">


<script type="text/javascript" src="/js/common_lib/jquery-1.7.min.js"> </script>
<script type="text/javascript" src="/js/my_lib_new/com.zpyr.js"> </script>
<script type="text/javascript" src="/js/my_lib_new/com.zpyr.data.js"> </script>
<script type="text/javascript" src="/js/my_lib_new/com.zpyr.web.js"> </script>
<script type="text/javascript" src="/js/home/index.js"> </script>
<script type="text/javascript">
	var myHistory , pLogin;
	
	$(document).ready(function() {
		console.log('$start_index');
		
<%
	if(isLogin) {
%>
	$('#s_menu_lgout').show();
	$('#s_menu_lgn').hide();
<%
	}
	else {
%>
	$('#s_menu_lgout').hide();
	$('#s_menu_lgn').show();
<%
	}
%>
		
		myHistory = new com.zpyr.web.Hist();
		myHistory.setTargetDiv('main_wrap');
		myHistory.addPage('', '/_blank.jsp');
		myHistory.addPage('dday', '/home/dday.zpr');
		myHistory.addPage('prof', '/home/profile.zpr');
		myHistory.addPage('memo', '/home/memo.zpr');
		myHistory.addPage('blog', '/home/blog.zpr');
		myHistory.addPage('html5', '/home/html5.zpr');
		// addPage 를 완료하면, myHistory.go(pageId) 를 통해서 원하는 페이지로 이동할 수 있다.
		
		/* navigation menu 를 위한 script start */
		
		myHistory.pageShowCB = function() {
			var pageId = myHistory.getPageId(location.href);
			$('#menu_' + pageId).addClass('menu_selected');
		};
		myHistory.hashChangeCB = function() {
			var pageId = myHistory.getPageId(location.href);
			$('#menu_' + pageId).addClass('menu_selected');
		};
		
		$('#menu_prof').click(function(){
			myHistory.go( 'prof' );
			$('nav a').removeClass('menu_selected');
			$(this).addClass('menu_selected');
		});
		$('#menu_memo').click(function(){
			myHistory.go( 'memo' );
			$('nav a').removeClass('menu_selected');
			$(this).addClass('menu_selected');
		});
		/* navigation menu 를 위한 script end */
		
		pLogin = new com.zpyr.web.Popup( 300 , 204 , 300 , 300 , '' , '/home/common/loginForm.zpr' );
		pLogin.setDrag(false);
		pLogin.close = pLogin.hide;
		
		window.onresize = function(e) {
			var left = $('#s_menu_lgn').offset().left + $('#s_menu_lgn').width() + 10 - 300;
			pLogin.setX(left);
		}
		
		$('#s_menu_lgn').click(function() {
			var top = $('#s_menu_lgn').offset().top;
			var left = $('#s_menu_lgn').offset().left + $('#s_menu_lgn').width() + 10 - 300;
			
			pLogin.setX(left);
			pLogin.setY(top);
			
			pLogin.show();
		});

		$('#s_menu_lgout').click(function() {
			var url = '/home/common/logout.zpr';
			if(confirm('Y/N')) {
				$.post(url , {} , function(data){
					location.reload();
				});	
			}
		});
		
	});
	

</script>


</head>
<body>
<article>

	<div id='header'>
		<div id='header_wrap'>
		<a href='javascript:;' class='txt_blue_btn login_btn' id='s_menu_lgn'>로그인</a>
		<a href='javascript:;' class='txt_blue_btn login_btn' id='s_menu_lgout'>로그아웃</a>
		<h1>Zepyr 홈페이지</h1>
		<nav>
		<a href='javascript:;' id='menu_prof'>프로필</a>
		<a href='javascript:;' id='menu_memo'>메모장</a>
		</nav>
		</div>
	</div>
	<br />
	<div id='main'>
		<div id='main_wrap'>
		</div>
	</div>
	<br /><br />
	<div id='footer'>
		<div id='footer_wrap'>
		footer
		</div>
	</div>

</article>
</body>
</html>